﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

using Framework.Graphics;

namespace Framework.GameStateManagment
{
    public class Input
    {
        private static KeyboardState _KS;
        private static MouseState _MS;
        private static Vector2 _movement;
        private static Vector2 _allMovement;
        private static float _speed;
        private static Vector2 _reduce;

        public static Vector2 Movement
        {
            get { return _movement; }
            set { _movement = value; }
        }

        public static Vector2 AllMovement
        {
            //get { return _allMovement - new Vector2(512, 384); }
            get { return _allMovement - _reduce; }
            set { _allMovement = value; }
        }

        public static void Init()
        {
            _movement = new Vector2(0, 0);
            _KS = Keyboard.GetState();
            _MS = Mouse.GetState();
            _speed = 2;
            _reduce = new Vector2(512, 384);
        }

        public static void Update()
        {
            _KS = Keyboard.GetState();
            _MS = Mouse.GetState();

            Camera.Update(MovementNow());
            _allMovement = Camera.Position;
        }

        public static KeyboardState KS
        {
            get { return _KS; }
        }

        public static MouseState MS
        {
            get { return _MS; }
        }

        public static Vector2 MovementNow()
        {
            Vector2 Temp = new Vector2(0, 0);
            _speed = 2f;

            if (KS.IsKeyDown(Keys.W))
            {
                Temp.Y += _speed;
            }
            if (KS.IsKeyDown(Keys.S))
            {
                Temp.Y -= _speed;
            }
            if (KS.IsKeyDown(Keys.A))
            {
                Temp.X += _speed;
            }
            if (KS.IsKeyDown(Keys.D))
            {
                Temp.X -= _speed;
            }

            return Temp;
        }
    }
}
